<? 
require 'config.php';
//change nhận các giá trị always,hourly,daily,weekly,monthly,yearly,never
//prio nhận các giá trị 0.0 -> 1.0
$sitemap = '';
$sitemap .= '<url>
                <loc>'.DOMAIN.'</loc>
                <changefreq>Hourly</changefreq>
                <priority>1.00</priority>
              </url>';
              
// Dịch vụ
$sitemap .= '<url>';
$sitemap .= '<loc>'.DOMAIN.'/dich-vu.html'.'</loc>';
$sitemap .= '<changefreq>Daily</changefreq>';
$sitemap .= '<priority>0.80</priority>';
$sitemap .= '</url>';

//các category dịch vụ
$db_menu = new db_query('SELECT cat_id,cat_type,cat_name 
                        FROM categories_multi
                        WHERE cat_type= "services"
                        LIMIT 10');
$list_cat = $db_menu->resultArray();unset($db_menu);
foreach($list_cat as $cat){
    $sitemap .= '<url>';
    $sitemap .= '<loc>'.DOMAIN.generate_service_cat_url($cat).'</loc>';
    $sitemap .= '<changefreq>Daily</changefreq>';
    $sitemap .= '<priority>0.80</priority>';
    $sitemap .= '</url>';
}

// Blog
$sitemap .= '<url>';
$sitemap .= '<loc>'.DOMAIN.'/blog.html'.'</loc>';
$sitemap .= '<changefreq>Daily</changefreq>';
$sitemap .= '<priority>0.80</priority>';
$sitemap .= '</url>';

//sitemap  
$sitemap .= '<url>';
$sitemap .= '<loc>'.DOMAIN.'/sitemap.xml'.'</loc>';
$sitemap .= '<changefreq>Daily</changefreq>';
$sitemap .= '<priority>0.80</priority>';
$sitemap .= '</url>';

//list bài dịch vụ mới
$db_query = new db_query('SELECT *
                          FROM services 
                          WHERE ser_active = 1
                          ORDER BY ser_id
                          LIMIT 30');
$list_new = $db_query->resultArray();unset($db_query);
foreach($list_new as $new){
    $sitemap .= '<url>';
    $sitemap .= '<loc>'.DOMAIN.generate_service_detail_url($new).'</loc>';
    $sitemap .= '<changefreq>Weekly</changefreq>';
    $sitemap .= '<priority>0.64</priority>';
    $sitemap .= '</url>';
}

//list bài blog mới
$db_query = new db_query('SELECT *
                          FROM blog
                          WHERE blo_active = 1 
                          ORDER BY blo_date DESC
                          LIMIT 30');
$list_new = $db_query->resultArray();unset($db_query);
foreach($list_new as $new){
    $sitemap .= '<url>';
    $sitemap .= '<loc>'.DOMAIN.generate_blog_detail_url($new).'</loc>';
    $sitemap .= '<changefreq>Weekly</changefreq>';
    $sitemap .= '<priority>0.64</priority>';
    $sitemap .= '</url>';
}
ob_clean();
?>
<?header ("Content-Type:text/xml");?>
<?php 
echo '<?xml version="1.0" encoding="UTF-8"?>';
?>
<urlset
      xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
      xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9
            http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">
<?=$sitemap?>
</urlset>
